package com.kfirszt.elearning.struts.actions;

import com.kfirszt.elearning.base.BaseAction;
import com.kfirszt.elearning.persistence.model.BaseEntity;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public abstract class BaseCrudAction<T extends BaseEntity> extends BaseAction implements
		Preparable, ModelDriven<T> {
	
	private static final long serialVersionUID = 1L;
	
	protected Long id;

	protected T entity;
	
	protected Boolean newInstance;

	@Override
	public T getModel() {
		return entity;
	}

	@Override
	public abstract void prepare() throws Exception;

	public T getEntity() {
		return entity;
	}

	public void setEntity(T entity) {
		this.entity = entity;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Boolean getNewInstance() {
		return newInstance;
	}

	public void setNewInstance(Boolean newInstance) {
		this.newInstance = newInstance;
	}

}
